<?php

namespace App\Providers;

use Illuminate\Support\Facades\DB;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Queue;
use Illuminate\Queue\Events\JobProcessed;
use Illuminate\Queue\Events\JobProcessing;
use Log;
class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //
        Queue::before(function (JobProcessing $event) {
            $date = date('Ym',strtotime("-1 month"));
            DB::table('request_success')->where('request_year_month',"$date")
                ->update(array(
                'status' => '送信機能処理中'
                ));
        });

        Queue::after(function (JobProcessed $event) {
            $date = date('Ym',strtotime("-1 month"));
            DB::table('request_success')->where('request_year_month',"$date")
                ->update(array(
                'status' => '送信機能処理完成しました'
            ));
        });
    }

}
